import { makeAutoObservable } from 'mobx';

class CommonStore {
  constructor() {
    makeAutoObservable(this);
  }

  // --- 距离顶部的安全距离 ---
  safeAreaTop = 0;

  /** 设置顶部安全区 */
  setSafeAreaTop(value: number) {
    this.safeAreaTop = value;
  }
  //距离底部的安全距离
  safeAreaBottom = 0;

  /** 设置底部安全区 */
  setSafeAreaBottom(value: number) {
    this.safeAreaBottom = value;
  }

  /** 页面距离顶部的距离包含TitleBar的44px距离 */
  pageAreaTop = 0;

  setPageAreaTop(value: number) {
    this.pageAreaTop = value;
  }

  //冷启动标记
  hasLaunched = false;
  setHasLaunched(value: boolean) {
    this.hasLaunched = value;
  }

  // 底部导航栏选中的标识默认首页0
  activeTab = 0;

  setActiveTab(index: number) {
    this.activeTab = index;
  }

  // 是否显示底部导航栏
  showTabBar = true;

  setShowTabBar(flag: boolean) {
    this.showTabBar = flag;
  }

  // 省份
  province = '';

  setProvince(val: string) {
    this.province = val;
  }

  // 省份的编码
  provinceCode = '';

  setProvinceCode(val: string) {
    this.provinceCode = val;
  }

  // 定位获取的市
  city = '';

  setCity(v: string) {
    this.city = v;
  }

  // 定位获取的市的编码
  cityCode = '';

  setCityCode(v: string) {
    this.cityCode = v;
  }

  // 登录后的token
  accessToken = '';

  setAccessToken(v: string) {
    this.accessToken = v;
  }

  //需要刷新
  needRefresh = false;

  setNeedRefresh(v: boolean) {
    this.needRefresh = v;
  }

  // 登录后首次进入首页需要更新用户信息
  needUpdateInfo = true;

  setNeedUpdateInfo(v: boolean) {
    this.needUpdateInfo = v;
  }

  // 查看图片的列表
  images = [];

  setImages(list: any) {
    this.images = list;
  }

  // 打开其中一张图片的图片索引
  initialIndex = 0;

  setInitialIndex(num: number) {
    this.initialIndex = num;
  }

  // 判断是否是ios设备
  isIos = false;

  setIsIos(flag: boolean) {
    this.isIos = flag;
  }

  //网络状态
  networkStatus = true;
  setNetworkStatus(status: boolean) {
    this.networkStatus = status;
  }

  //商城半屏跳转的地址
  pagePath = '';

  setPagePath(path:string) {
    this.pagePath = path;
  }
}
export default new CommonStore();
